#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "cpp/QmlInBook/QmlBaseSynctaxObject/basesynctax.h"
#include <QDebug>
#include <QQuickView>
#include <QQuickItem>
#include "cpp/QmlInBook/cqmlbasesynctax.h"

//#include "cpp/FFmpeg/imp/demo1.h"

int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

    QGuiApplication app(argc, argv);
    //qmlRegisterType注册C++类型至QML
    //arg1:import时模块名
    //arg2:主版本号
    //arg3:次版本号
    //arg4:QML类型名
    qmlRegisterType<BaseSynctaxCpp>("MyBaseSynctaxCpp",1,0,"BaseSynctaxCpp");//C++注册到QML
    //qmlRegisterType<CDemo1>("CDemo1", 1,0, "CDemo1");

    //QQuickView view(QUrl("qrc:/main.qml"));
    //view.show();

    //CQmlBaseSynctaxCpp::Instance()->setObj(view.rootObject());


    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);
    CQmlBaseSynctaxCpp::Instance()->setObj(engine.rootObjects().first());
    return app.exec();
}
